/*
 * writeFile.cpp
 *
 *  Created on: 14/02/2014
 *      Author: root
 */

#include "signatures.h"
#include <iostream>
#include <fstream>
using namespace std;

int writeFile(const char * fileName, int n, int T, int * numP, int ** P, int * M, int ** times, int ** costs){

	ofstream file(fileName);

	if (!file.is_open()){
		return 1;
	}

	//Imprimir fila 1: Numero de actividades y deadline
	file << n << " " << T << endl << endl;


	//Imprimir arreglo de predecesores
	file << "#Preds" << endl;

	for (int i = 0; i < n; i++){

		for (int j = 0; j < numP[i]; j++) {

			file << P[i][j] << " ";

		}

		if (numP[i] == 0){
			file << " ";
		}

		file << "." << endl;

	}

	file << endl;


	//Imprimir modos
	file << "#Modes (cost,time)" << endl;

	for (int i = 0; i < n; i++){

		for (int j = 0; j < M[i]; j++) {

			file << "(" << costs[i][j] << "," << times[i][j] << ") ";

		}

		file << "." << endl;

	}

	file << endl;

	file.close();

	return 0;

}
